package cn.tedu.lucky.draw.server.job.listener;

import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;

public class CsvToDBListener implements JobExecutionListener {
    @Override
    public void beforeJob(JobExecution jobExecution) {
        long begin = System.currentTimeMillis();
        jobExecution.getExecutionContext().putLong("begin", begin);
        System.out.println("CsvToDBListener.beforeJob() begin: " + begin);
    }

    @Override
    public void afterJob(JobExecution jobExecution) {
        long end = System.currentTimeMillis();
        long begin = jobExecution.getExecutionContext().getLong("begin");
        System.out.println("------作业执行结束，总共耗时：" + (end - begin) + "毫秒-----------");
    }
}
